package com.example.demo.mapper.sysdict;

import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.bean.PageRes;
import com.example.demo.bean.sysdict.SysDictTypeDO;
import com.example.demo.mapper.BaseMapperX;
import com.example.demo.dto.sysdict.SysDictTypePageReqVO;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface SysDictTypeMapper extends BaseMapperX<SysDictTypeDO> {
    default PageRes<SysDictTypeDO> selectPage(SysDictTypePageReqVO reqVO) {
        Page<SysDictTypeDO> page = new Page<>(reqVO.getPageNo(), reqVO.getPageSize());
        return selectPageCommon(page, new QueryWrapper<SysDictTypeDO>()
                .like(ObjectUtil.isNotNull(reqVO.getDictName()), "dict_name", reqVO.getDictName())
                .like(ObjectUtil.isNotNull(reqVO.getDictCode()), "dict_code", reqVO.getDictCode())
                .between(ObjectUtil.isNotNull(reqVO.getTimeArr()), "create_time", ArrayUtil.get(reqVO.getTimeArr(), 0), ArrayUtil.get(reqVO.getTimeArr(), 1)));
    }
}
